package com.china08.yxyapi.api.manage.tec.teaching.live.myClassSchedule;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;

import org.apache.commons.lang3.StringUtils;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiReqModel;

import io.swagger.annotations.ApiOperation;

/**
 * 我的教学-直播课-教师-我的课表-课程关注
 * @author 赵亚辉
 *
 */
@CrossOrigin
@RestController
public class MyAttentionLessonController extends YxyApiBaseController{
	
	private static final Logger logger=Logger.getLogger(MyClassScheduleController.class);
	
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@ApiOperation(value = "我的关注操作")
    @RequestMapping(value = "/api_yw/manage/tec/teaching/live/myAttentionLesson/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@Transactional
	public String updateMyAttentionLesson(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel reqModel) {
		
		String teacherId = getProfile(request, response).getId();
		String lessonId=reqModel.lessionId;
		
		String sql="delete from yxy_live.yxy_live_user_favor where user_id='"+teacherId+"' and live_lesson_id='"+lessonId+"'";
		jdbcTemplate.execute(sql);
		
		return "success";
	}
	
	protected static class ReqModel extends YxyApiReqModel{
		
		public String lessionId;
		
		@Override
        public void autoCheck() {
            Assert.notNull(StringUtils.defaultIfBlank(lessionId, null), "请填写课程id");
        }
	}
	
}
